﻿namespace Contoso.ActiveDirectory {

    /// <summary>
    /// http://msdn.microsoft.com/en-us/library/cc223367.aspx
    /// The following sections describe the matching rules supported by DCs when performing LDAP search requests. 
    /// Unlike, for example, extended controls and extended operations, there is no attribute exposed by the DC that specifies 
    /// which matching rules it supports. The identifiers for these matching rules are used in an extensibleMatch clause in the 
    /// Filter portion of a SearchRequest, as described in [RFC2251] section 4.5.1. 
    /// </summary>
    /// <remarks>
    /// Performance using these controls is poor due to indexes of the attribute searched are disabled.
    /// Best used when preeded by another indexed attribute
    /// </remarks>
    public static class LdapMatchingRules {

        /// <summary>
        /// This rule is equivalent to a bitwise "AND" operation. When this matching rule is used as a clause in a query filter, 
        /// the clause is satisfied only if all the bits set to '1' in the value included in the clause correspond to bits set to '1' in the value stored in the directory.
        /// </summary>
        public const string LDAP_MATCHING_RULE_BIT_AND = "1.2.840.113556.1.4.803";

        /// <summary>
        /// This rule is equivalent to a bitwise "OR" operation. When this matching rule is used as a clause in a query filter, 
        /// the clause is satisfied only if at least one of the bits set to '1' in the value included in the clause corresponds to a bit set to '1' in the value stored in the directory.
        /// </summary>
        public const string LDAP_MATCHING_RULE_BIT_OR = "1.2.840.113556.1.4.804";

        /// <summary>
        /// This rule provides recursive search of a link attribute. A filter F of the form "(A: 1.2.840.113556.1.4.1941:=V)", 
        /// where A is a link attribute and V is a value, evaluates to True for an object whose DN is D if the following method 
        /// EvalTransitiveFilter(A, V, D) returns true, and False if the method returns false. 
        /// If A is not a link attribute, the filter F evaluates to Undefined.
        /// </summary>
        /// <example>
        /// (&(objectCategory=group)(member:1.2.840.113556.1.4.1941:=CN=jsmith,OU=Users,DC=contoso,DC=com))
        /// </example>
        public const string LDAP_MATCHING_RULE_TRANSITIVE_EVAL = "1.2.840.113556.1.4.1941";

        /// <summary>
        /// This rule provides a way to match on portions of values of syntax Object(DN-String) and Object(DN-Binary).
        /// Let F be a filter of the form "(A: 1.2.840.113556.1.4.2253:=V)", where A is a link attribute and V is a value of syntax
        /// Object(DN-String) (section 3.1.1.2.2.2.1) or Object(DN-Binary) (section 3.1.1.2.2.2.3). 
        /// This filter evaluates to True for an object whose DN is D if the method defined below, EvalDNWithDataFilter(A,V,D), returns true, 
        /// and False if the method returns false. If A is not of syntax Object(DN-String) or Object(DN-Binary), the filter F evaluates to Undefined.
        /// </summary>
        public const string LDAP_MATCHING_RULE_DN_WITH_DATA = "1.2.840.113556.1.4.2253";
    }
}
